package com.beep.erp.model.goodsdetail;

import com.beep.erp.common.bean.GoodsDetailBean;
import com.beep.erp.common.bean.StockInDetailBean;
import com.beep.erp.http.HttpExceptionHandle;
import com.beep.erp.http.HttpResultSubscriber;
import com.beep.erp.model.stockIn.stockindetail.StockInDetailContract;

import rx.schedulers.Schedulers;

/**
 * Created by Jolly on 2018/9/2.
 */

public class GoodsDetailPresenter extends GoodsDetailContract.Presenter {
    @Override
    public void getGoodsDetail(String sign, String timeStamp, String stockId) {
        mRxManage.add(mModel.getGoodsDetail(sign, timeStamp, stockId).unsubscribeOn(Schedulers.io()).subscribe(new HttpResultSubscriber<GoodsDetailBean>() {
            @Override
            public void onError(HttpExceptionHandle.ResponeThrowable e) {
                mView.hideLoading();
                mView.showMessage(e.ErrorInfo);
            }

            @Override
            public void onNext(GoodsDetailBean goodsDetailBean) {
                mView.hideLoading();
                mView.getGoodsDetail(goodsDetailBean);
            }
        }));
    }

    @Override
    public void onStart() {
        mView.getDate();
    }

}
